"""
basic net class
"""
import ops


class net:

    def __init__(self):
        self.layers = []

    def __call__(self, inputs, target):
        return inputs

    @property
    def depth(self):
        return len(self.layers)

    def init_layers(self):
        for key, value in self.__dict__.items():
            if key == "layers":
                continue
            self.layers.append(value)

    def backward(self):
        pass

    def updateParams(self, optimizer):
        params, grads = [], []
        for each in self.layers:
            if isinstance(each, ops.MetaDense):
                params.append(each.w)
                grads.append(each.dw)
            if isinstance(each, ops.Convolution):
                params.append(each.W)
                params.append(each.b)
                grads.append(each.dW)
                grads.append(each.db)
        optimizer(params, grads)
